﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Resources;
using System.Reflection;

namespace Utility
{
    public class ResourceServiceLocator
    {
        /// <summary>
        /// Get resource string
        /// </summary>
        /// <param name="asm">assembly</param>
        /// <param name="baseName">class namespace</param>
        /// <param name="resourceName">resource key</param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public static string GetResourceString(Assembly asm, string baseName, string resourceName, System.Globalization.CultureInfo culture)
        {
            try
            {
                ResourceManager rm = new ResourceManager(baseName, asm);
                rm.IgnoreCase = true;
                return rm.GetString(resourceName, culture);
            }
            catch (MissingManifestResourceException)
            {

            }
            return null;
        }

        /// <summary>
        /// Get resource object
        /// </summary>
        /// <param name="asm">assembly</param>
        /// <param name="baseName">class namespace</param>
        /// <param name="resourceName">resource key</param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public static object GetResourceObject(Assembly asm, string baseName, string resourceName, System.Globalization.CultureInfo culture)
        {
            try
            {
                ResourceManager rm = new ResourceManager(baseName, asm);
                rm.IgnoreCase = true;
                return rm.GetObject(resourceName, culture);
            }
            catch (MissingManifestResourceException)
            {

            }
            return null;
        }

    }//
}//
